package com.kb.design.controller.chart;

import com.kb.design.common.ApiResponse;
import com.kb.design.dto.QueryChartDTO;
import com.kb.design.service.AdminHomeService;
import com.kb.design.service.chart.GeneralHomeService;
import com.kb.design.vo.chart.MonthlyPerformanceVO;
import org.aspectj.weaver.ast.Var;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 员工首页
 */
@RestController
@RequestMapping("/generalHome")
public class GeneralHomeController {

    @Resource
    private GeneralHomeService generalHomeService;

    /**
     * 绩效情况
     */
    @PostMapping("/queryPerformanceInfo")
    public ApiResponse queryPerformanceInfo(@RequestBody QueryChartDTO queryChartDTO) {
        return ApiResponse.success(generalHomeService.queryPerformanceInfo(queryChartDTO));
    }

    /**
     * 在职项目统计
     */
    @RequestMapping("/projectNumberCount")
    public ApiResponse projectNumberCount(@RequestBody QueryChartDTO queryChartDTO) {
        return ApiResponse.success(generalHomeService.projectNumberCount(queryChartDTO));
    }

    /**
     * 年度绩效统计
     */
    @RequestMapping("/getMonthlyPerformanceByUserCode")
    public ApiResponse getMonthlyPerformanceByUserCode(@RequestBody QueryChartDTO queryChartDTO) {
        Map<String, Object> result = new HashMap<>();
        /**
         * 月份数组 默认1-12
         */
        String[] monthArray = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
        List<MonthlyPerformanceVO> monthlyPerformanceByUserCode = generalHomeService.getMonthlyPerformanceByUserCode(queryChartDTO);
        result.put("monthArray", monthArray);
        result.put("data", monthlyPerformanceByUserCode);
        return ApiResponse.success(result);
    }
}
